package com.etc.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.etc.entity.Travels;
import com.etc.service.TravelsService;

@Controller
@RequestMapping
public class HomePageController {

	@Resource
	private TravelsService ts;

	@RequestMapping(value = "home", method = RequestMethod.GET)
	public String toHomePage(ModelMap modelMap,HttpSession session) {
		List<Travels> list = ts.selectAll();
		session.setAttribute("Travels", list);
		// System.out.println(home);
		modelMap.put("flag", "home");
		return "home";
	}

	@RequestMapping(value = "area", method = RequestMethod.GET)
	public String toArea(ModelMap modelMap) {
		modelMap.put("flag", "area");
		return "area";
	}

	@RequestMapping(value = "route", method = RequestMethod.GET)
	public String toRoute(ModelMap modelMap) {
		modelMap.put("flag", "route");
		return "route";
	}

	@RequestMapping(value = "sharing", method = RequestMethod.GET)
	public String toSharing(ModelMap modelMap) {
		modelMap.put("flag", "sharing");
		return "sharing";
	}

	@RequestMapping(value = "carousel_1", method = RequestMethod.GET)
	public String toCarousel_1(ModelMap modelMap) {
		modelMap.put("flag", "carousel_1");
		return "carousel_1";
	}

	@RequestMapping(value = "scenics/{keyword}/{sequence}", method = RequestMethod.GET)
	public String toScenicDetails(@ModelAttribute("keyword") String keyword,
			@ModelAttribute("sequence") String sequence, ModelMap modelMap) {
		modelMap.put("flag", "area");
		return "scenicDetails";
	}
	
}
